<template>
	<view class="mainpadding">
		<view class="flexbetween xiahuaxian" @click="jumper('/pages/system?type=4')">
			<view class="ershiba zhonghei">关于我们</view>
			<u-icon name="arrow-right" color="#999999"></u-icon>
		</view>
		<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages/system?type=1')">
			<view class="ershiba zhonghei">用户协议</view>
			<u-icon name="arrow-right" color="#999999"></u-icon>
		</view>
		<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages/system?type=2')">
			<view class="ershiba zhonghei">隐私保护政策</view>
			<u-icon name="arrow-right" color="#999999"></u-icon>
		</view>
		<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_homepage/shouhuodizhi')">
			<view class="ershiba zhonghei">收货地址</view>
			<u-icon name="arrow-right" color="#999999"></u-icon>
		</view>
		<view class="flexbetween xiahuaxian margin_top" @click="zxshow=true">
			<view class="ershiba zhonghei">注销账号</view>
			<u-icon name="arrow-right" color="#999999"></u-icon>
		</view>
		<u-modal :show="show" cancelColor="#555" confirmColor="#ff9341" :showCancelButton="true" :title="title"
			@cancel="show=false" @confirm="confirm"></u-modal>
		<u-modal title='警告' :show="zxshow" content="账号注销后，您的系统数据将不再可用。请慎重处理!!!" @confirm="zxconfirm" style='text-align: center;' confirmColor="#999"
			confirmText="确认注销" cancelText="再想想" cancelColor="#ff9341" buttonReverse showCancelButton
			@cancel='zxshow=false'></u-modal>
		<view class="mainpadding gudingdb" @click="show = true">
			<view class="bigbtn">退出登录</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				httpRequest,
				userInfo: {},
				show: false,
				zxshow:false,
				title: '确定要退出当前账户么？',
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			zxconfirm() {
				this.zxshow = false;
				httpRequest.request('/api/user/zxUser', 'POST', {
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg);
					if(res.code==1){
						uni.clearStorageSync();
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			},
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			confirm() {
				this.show = false;
				// 将存储的数据改为空达到退出登录的效果
				uni.removeStorageSync('token');
				uni.removeStorageSync('user_id');
				httpRequest.toast("退出登录成功")
				setTimeout(()=>{
					uni.navigateBack(1)
				},1000)
			},
			jumper(url) {
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.hhbtn {
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 41rpx;
		width: 100%;
		height: 82rpx;
		font-size: 32rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		background-color: #A4A4A4;
	}
</style>